package cn.wetcland.type;

import cn.wetcland.custom.CustomItemStack;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ItemStackTypeHandler implements TypeHandler<CustomItemStack> {
    @Override
    public void setParameter(PreparedStatement preparedStatement, int i, CustomItemStack itemStack, JdbcType jdbcType) throws SQLException {
        preparedStatement.setObject(i, itemStack);
    }

    @Override
    public CustomItemStack getResult(ResultSet resultSet, String s) throws SQLException {
        return (CustomItemStack) resultSet.getObject(s);
    }

    @Override
    public CustomItemStack getResult(ResultSet resultSet, int i) throws SQLException {
        return (CustomItemStack) resultSet.getObject(i);
    }

    @Override
    public CustomItemStack getResult(CallableStatement callableStatement, int i) throws SQLException {
        return (CustomItemStack) callableStatement.getObject(i);
    }
}
